<template>
  <div class="box">
    <!-- 左上图标 -->
    <div class="left" @click="left"><i class="van-icon van-icon-arrow-left"></i></div>
    <!-- 轮播 -->
    <van-swipe :loop="false">
      <van-swipe-item v-for="item in list" :key="item.id">
        <img :src="list.pic" alt="" />
      </van-swipe-item>
    </van-swipe>

    <!-- 标题简述 -->
    <div class="title">
      <p>{{ list.name }}</p>
      <p>
        <span>{{ list.characteristic }}</span>
      </p>
      <ul>
        <li>
          <div><small>低价</small> ￥{{ list.minPrice }}</div>
          <div>
            <small>原价 ￥ {{ list.originalPrice }} </small>
          </div>
        </li>
        <li>
          <small>库存 {{ list.views }} </small>
        </li>
      </ul>
    </div>

    <!-- 底部加入购物车 -->
    <ul class="footer">
      <li><i class="el-icon-service"></i></li>
      <li @click="$router.push('/shopcar')">
        <i class="van-icon van-icon-shopping-cart-o"></i>
      </li>
      <li><i class="xinone van-icon van-icon-star-o"></i></li>
      <li>立即购买</li>
      <li @click="add(list)">加入购物车</li>
    </ul>
  </div>
</template>

<script>
export default {
  data() {
    return {
      list: this.$route.query.item,
    };
  },
  mounted() {
    
  },
  methods: {
    left(){
      this.$router.go(-1)
    },
    add(item) {
      this.$store.commit("add", item);
      Toast.success('加入成功');
    },
    
  },
};
</script>

<style lang="scss" scoped>
.box {
  // 左上图标
  .left {
    position: fixed;
    top: 0.2rem;
    left: 0.2rem;
    z-index: 5;
    border: 0.01rem solid #fff;
    border-radius: 50%;
    width: 0.68rem;
    height: 0.68rem;
    text-align: center;
    box-sizing: border-box;
    i {
      color: #666;
      font-size: 0.4rem;
      display: block;
      width: 0.519rem; //25.95
      height: 0.519rem;
      line-height: 0.519rem;

      border: 0.01rem solid #fff;
      background-color: #fff;
      border-radius: 50%;
      position: absolute;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
    }
  }
  font-size: 0.2884rem; //14.42
  // 轮播
  .van-swipe-item {
    width: 100%;
    height: 7.5rem; //375
    img {
      width: 100%;
      height: 100%;
    }
  }
  //  标题简述
  .title {
    box-sizing: border-box;
    width: 100%;
    height: 1.9rem; //99.5
    margin-top: 0.4rem;
    padding: 0 0.15rem 0 0.3rem;
    border-bottom: 0.2rem solid #f5f5f5;
    > p {
      span {
        font-size: 0.24rem; //12
        color: #b2b2b2;
      }
    }
    p:nth-of-type(1) {
      font-size: 0.318rem; //15.9
    }
    p:nth-of-type(2) {
      margin: 0.2rem 0;
    }
    ul {
      display: flex;
      align-items: center;
      width: 100%;
      justify-content: space-between;
      color: #b8b8b8;
      li:nth-child(1) {
        color: #cc0c0c;
        display: flex;
        align-items: center;
        div:nth-child(2) {
          color: #b8b8b8;
          margin-left: 0.15rem;
        }
      }
    }
  }

  // 底部加入购物车
  .footer {
    display: flex;
    align-items: center;
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 1rem;
    line-height: 1rem;
    border-top: 0.01rem solid #e9e9e9;
    box-shadow: 0 0 5px 1px #bebebe;
    li {
      text-align: center;
      border-right: 0.01rem solid #e9e9e9;
    }
    li:nth-child(1),
    li:nth-child(2),
    li:nth-child(3) {
      width: 1.1rem;
      font-size: 0.45rem;
    }
    li:nth-child(4),
    li:nth-child(5) {
      width: 2.1rem;
    }
    li:nth-child(5) {
      border-right: 0;
      background: #b7282e;
      color: white;
    }
  }
}
</style>
